package logic

import (
	"context"
	"errors"
	"house_srv/models/mysql"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateHouseExamineLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateHouseExamineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateHouseExamineLogic {
	return &UpdateHouseExamineLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateHouseExamineLogic) UpdateHouseExamine(in *house.UpdateHouseExamineRequest) (*house.UpdateHouseExamineResponse, error) {
	// todo: add your logic here and delete this line
	m := mysql.House{}
	m.HouseStatus = in.HouseStatus
	m.HouseExamine = in.HouseExamine
	err := m.UpdateHouseExamine(in.HouseId)
	if err != nil {
		logx.Info("审核修改状态失败", err)
		return nil, errors.New("审核修改状态失败")
	}
	return &house.UpdateHouseExamineResponse{
		HouseId: int64(m.ID),
	}, nil
}
